﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleApp7
{
    class Program
    {

        public static void PrintValue(IEnumerable<Int32> c)
        {
            IEnumerator<Int32> cEnumerator = c.GetEnumerator();
            while (cEnumerator.MoveNext())
            {
                Console.Write(cEnumerator.Current + " ");
            }
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            Queue<Int32> intQ = new Queue<int>();

            for (int i = 0; i < 5; i++)
            {
                intQ.Enqueue(i * 5);
            }
            
            
           PrintValue(intQ);

             
            intQ.Dequeue();
            PrintValue(intQ);

             
            Console.WriteLine(intQ.Peek());

            Console.ReadLine();




            var myQueue = new Queue<string>();
            myQueue.Enqueue("first in line"); 
            myQueue.Enqueue("second in line");
            myQueue.Enqueue("third in line");
            myQueue.Enqueue("last in line");
            var takeALook = myQueue.Peek(); 
            var getFirst = myQueue.Dequeue(); 
            var getNext = myQueue.Dequeue();
            var howMany = myQueue.Count; 
            myQueue.Clear(); 
            Console.WriteLine("Peek() return: {0}" + Environment.NewLine +
             "first dequeue return: {1}" + Environment.NewLine +
             "second dequeue return: {2}" + Environment.NewLine +
             "two dequeue  return count: {3}" + Environment.NewLine,
             takeALook, getFirst, getNext, howMany);
            Console.ReadKey();

            

            Queue queue = new Queue();
            queue.Enqueue("Hello");
            queue.Enqueue("Hi");
            queue.Enqueue("Good");
            Console.WriteLine(" 新的一天开始啦");

            while (queue.Count!=0)
            {
                Console.WriteLine(queue.Dequeue());
            }
            Console.WriteLine("新的一天结束了哦！");


            queue.Enqueue("明天你好");
            queue.Enqueue("未来可期");
            queue.Enqueue("阳光正好");
            object[] obj = queue.ToArray();
            foreach (var v in obj)
            {
                Console.WriteLine(v);
            }



            
            queue.Enqueue(" 明天会更好");
            queue.Enqueue("有你，有我才有未来");
            queue.Enqueue("因为遇见你");
            IEnumerator enumerator = queue.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }




            Queue q = new Queue();

            q.Enqueue('Y');
            q.Enqueue('I');
            q.Enqueue('I');
            q.Enqueue('B');
            q.Enqueue('A');
            q.Enqueue('I');

            Console.WriteLine("Current queue: ");
            foreach (char c in q) Console.Write(c + " ");

            Console.WriteLine();
            q.Enqueue('.');
            q.Enqueue('C');
            q.Enqueue('O');
            q.Enqueue('M');
            Console.WriteLine("Current queue: ");
            foreach (char c in q) Console.Write(c + " ");

            Console.WriteLine();
            Console.WriteLine("Removing some values ");
            char ch = (char)q.Dequeue();
            Console.WriteLine("The removed value: {0}", ch);
            ch = (char)q.Dequeue();
            Console.WriteLine("The removed value: {0}", ch);

            Console.ReadKey(); 





        }


    }
}
